package cn.foolishbird.crow.step;

/**
 * @author foolish bird
 * @email luohongtu@foolishbird.cn
 */
public abstract class PageExecutorReadOnlyIterator<E> implements ReadOnlyIterator<E> {

    /**
     * 前进步数
     */
    protected int forward = 1;

    /**
     * 分页页数
     */
    protected ThreadLocal<Integer> pageNum = new ThreadLocal<>();

    /**
     * 一页多少数据
     */
    protected int pageSize = 400;

    public PageExecutorReadOnlyIterator() {
    }

    public PageExecutorReadOnlyIterator(int pageSize) {
        this.pageSize = pageSize;
    }

    public PageExecutorReadOnlyIterator(int forward, int pageSize) {
        this.forward = forward;
        this.pageSize = pageSize;
    }

    @Override
    public void forward() {
        this.pageNum.set(this.pageNum.get() + forward);
    }

    public int getForward() {
        return forward;
    }

    public void setForward(int forward) {
        this.forward = forward;
    }

    public int getPageNum() {
        return pageNum.get();
    }

    public void setPageNum(int pageNum) {
        this.pageNum.set(pageNum);
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

}
